package com.xyzq.model.ya.data;

import java.io.Serializable;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.appfuse.model.BaseObject;

@Entity
@Table(name = "staff")
public class Staff extends BaseObject implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7446384910677418129L;
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;
	@Column(unique = true, nullable = false)
	private Integer staffId;
	private String name;
	private String dept;
	private Integer team;
	@Column(nullable = false)
	private boolean leader;
	@Column(nullable = false)
	private boolean manager;
	@Column(nullable = false)
	private boolean status;
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "sub_time")
	private Date subTime;
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "modify_time")
	private Date modifyTime;
	private String remark;
	@OneToMany(mappedBy = "staff", cascade = CascadeType.ALL)
	private Set<Account> accounts = new HashSet<Account>();
	@OneToMany(mappedBy = "staff", cascade = CascadeType.ALL)
	private Set<StaffSellFund> sellFunds = new HashSet<StaffSellFund>();
	@OneToMany(mappedBy = "staff", cascade = CascadeType.ALL)
	private Set<StaffMonthReport> monthReports = new HashSet<StaffMonthReport>();

	public Long getId() {
		return id;
	}

	public Integer getStaffId() {
		return staffId;
	}

	public String getName() {
		return name;
	}

	public String getDept() {
		return dept;
	}

	public Integer getTeam() {
		return team;
	}

	public boolean isLeader() {
		return leader;
	}

	public boolean isManager() {
		return manager;
	}

	public boolean isStatus() {
		return status;
	}

	public Date getSubTime() {
		return subTime;
	}

	public Date getModifyTime() {
		return modifyTime;
	}

	public String getRemark() {
		return remark;
	}

	public Set<Account> getAccounts() {
		return accounts;
	}

	public Set<StaffSellFund> getSellFunds() {
		return sellFunds;
	}

	public Set<StaffMonthReport> getMonthReports() {
		return monthReports;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setStaffId(Integer staffId) {
		this.staffId = staffId;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setDept(String dept) {
		this.dept = dept;
	}

	public void setTeam(Integer team) {
		this.team = team;
	}

	public void setLeader(boolean leader) {
		this.leader = leader;
	}

	public void setManager(boolean manager) {
		this.manager = manager;
	}

	public void setStatus(boolean status) {
		this.status = status;
	}

	public void setSubTime(Date subTime) {
		this.subTime = subTime;
	}

	public void setModifyTime(Date modifyTime) {
		this.modifyTime = modifyTime;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public void setAccounts(Set<Account> accounts) {
		this.accounts = accounts;
	}

	public void setSellFunds(Set<StaffSellFund> sellFunds) {
		this.sellFunds = sellFunds;
	}

	public void setMonthReports(Set<StaffMonthReport> monthReports) {
		this.monthReports = monthReports;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((dept == null) ? 0 : dept.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + (leader ? 1231 : 1237);
		result = prime * result + (manager ? 1231 : 1237);
		result = prime * result
				+ ((modifyTime == null) ? 0 : modifyTime.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + ((remark == null) ? 0 : remark.hashCode());
		result = prime * result + ((staffId == null) ? 0 : staffId.hashCode());
		result = prime * result + (status ? 1231 : 1237);
		result = prime * result + ((subTime == null) ? 0 : subTime.hashCode());
		result = prime * result + ((team == null) ? 0 : team.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Staff other = (Staff) obj;
		if (dept == null) {
			if (other.dept != null)
				return false;
		} else if (!dept.equals(other.dept))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (leader != other.leader)
			return false;
		if (manager != other.manager)
			return false;
		if (modifyTime == null) {
			if (other.modifyTime != null)
				return false;
		} else if (!modifyTime.equals(other.modifyTime))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (remark == null) {
			if (other.remark != null)
				return false;
		} else if (!remark.equals(other.remark))
			return false;
		if (staffId == null) {
			if (other.staffId != null)
				return false;
		} else if (!staffId.equals(other.staffId))
			return false;
		if (status != other.status)
			return false;
		if (subTime == null) {
			if (other.subTime != null)
				return false;
		} else if (!subTime.equals(other.subTime))
			return false;
		if (team == null) {
			if (other.team != null)
				return false;
		} else if (!team.equals(other.team))
			return false;
		return true;
	}

	@Override
	public String toString() {
		ToStringBuilder builder = new ToStringBuilder(this);
		builder.append("id", id);
		builder.append("staffId", staffId);
		builder.append("name", name);
		builder.append("dept", dept);
		builder.append("team", team);
		builder.append("leader", leader);
		builder.append("manager", manager);
		builder.append("status", status);
		builder.append("subTime", subTime);
		builder.append("modifyTime", modifyTime);
		builder.append("remark", remark);
		return builder.toString();
	}

}
